package com.hdcircles.autoform.ui.label.fragment;

import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.cengalabs.flatui.FlatUI;
import com.hdcircles.autoform.R;
import com.hdcircles.autoform.base.SimpleFragment;
import com.hdcircles.autoform.ui.label.activity.AddSurveyActivity;
import com.hdcircles.autoform.ui.label.adapter.LabelMainAdapter;
import com.hdcircles.autoform.ui.main.activity.MainActivity;
import com.hdcircles.autoform.util.CircularAnimUtil;
import com.melnykov.fab.FloatingActionButton;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by hdcircles on 2016/9/27.
 */

public class LabelMainFragment extends SimpleFragment implements View.OnClickListener{

    @BindView(R.id.vp_label_main)
    ViewPager vpLabelMain;
    FloatingActionButton fabAdd;

    List<Fragment> fragments=new ArrayList<>();
    List<String> fragmentTitleList=new ArrayList<>();

    LabelMainAdapter mAdapter;
    private ShareLabelFragment shareLabelFragment;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_label_main;
    }

    @Override
    protected void initEventAndData() {
        shareLabelFragment = new ShareLabelFragment();
        fragments.add(new MyLabelsFragment());
        fragments.add(shareLabelFragment);
        fragmentTitleList.add("我的表单");
        fragmentTitleList.add("收到的表单");
        mAdapter=new LabelMainAdapter(getChildFragmentManager(),fragments,fragmentTitleList);
        vpLabelMain.setAdapter(mAdapter);
        TabLayout tabLabelMain=((MainActivity)getActivity()).getTabLabelMain();
        tabLabelMain.setBackground(FlatUI.getActionBarDrawable(getActivity(),FlatUI.SEA,false));
        tabLabelMain.setupWithViewPager(vpLabelMain);
        fabAdd=((MainActivity)getActivity()).getFabAdd();
        fabAdd.setOnClickListener(this);
    }



    private void addForm(){
        Intent intent=new Intent(mContext, AddSurveyActivity.class);
        CircularAnimUtil.startActivity(mActivity,intent,fabAdd,R.color.fab_bg);
    }

    @Override
    public void onClick(View view) {
        addForm();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}
